//package com.bangdream.michelia.view.fragment.main.home;
//
//import android.content.Intent;
//import android.os.Bundle;
//import android.support.annotation.Nullable;
//import android.support.v7.widget.LinearLayoutManager;
//import android.support.v7.widget.RecyclerView;
//import android.view.LayoutInflater;
//import android.view.View;
//import android.view.ViewGroup;
//
//import com.andview.refreshview.XRefreshView;
//import com.bangdream.michelia.R;
//import com.bangdream.michelia.contract.CoursesContract;
//import com.bangdream.michelia.entity.CommentBean;
//import com.bangdream.michelia.entity.CoursesTypeBean;
//import com.bangdream.michelia.entity.courses.CoursesBean;
//import com.bangdream.michelia.entity.courses.TeacherListBean;
//import com.bangdream.michelia.presenter.CoursesPresenter;
//import com.bangdream.michelia.utils.PublicResources;
//import com.bangdream.michelia.view.activity.curriculum.CurriculumDetails;
//import com.bangdream.michelia.view.adapter.CourseTypeAdapter;
//import com.bangdream.michelia.view.adapter.TaskCurriculumAdapter;
//import com.bangdream.michelia.view.fragment.currency.LazyLoadFragment;
//import com.chad.library.adapter.base.BaseQuickAdapter;
//
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//
///**
// * @date on 2018/6/18 17:13
// * @email 909732184@qq.com
// * 精品课程  专题课程 任务课程
// */
//public class QualityCurriculumList extends LazyLoadFragment<CoursesContract.ICoursesView,CoursesPresenter<CoursesContract.ICoursesView>>
//        implements CoursesContract.ICoursesView{
//    private View view;
//    //刷新加载控件
//    private XRefreshView refreshView;
//    private RecyclerView recyclerView;
//    private LinearLayoutManager linearLayoutManager;
////    private TaskCurriculumAdapter adapter;
//    private CourseTypeAdapter adapter;
//
//    private int page = 1;
//    private List<CoursesBean> dataList;
//    @Nullable
//    @Override
//    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
//        view = inflater.inflate(R.layout.recycler_view_layout,container,false);
//        return view;
//    }
//
//    @Override
//    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
//        super.onViewCreated(view, savedInstanceState);
//        initView();
//        setListener();
//    }
//
//    private void setListener() {
//        refreshView.setXRefreshViewListener(new XRefreshView.SimpleXRefreshListener(){
//            @Override
//            public void onRefresh(boolean isPullDown) {
//                super.onRefresh(isPullDown);
//                page = 1;
//                loadData();
//            }
//
//            @Override
//            public void onLoadMore(boolean isSilence) {
//                super.onLoadMore(isSilence);
//                page++;
//                loadData();
//            }
//        });
//
//        adapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
//            @Override
//            public void onItemClick(BaseQuickAdapter a, View view, int position) {
//                Intent intent = new Intent(getActivity(),CurriculumDetails.class);
//                intent.putExtra("id",adapter.getData().get(position).getId());
//                List<TeacherListBean> teacherList = adapter.getData().get(position).getTeacherList();
//                if(teacherList!=null && teacherList.size()>0)
//                    intent.putExtra("teacherId",teacherList.get(0).getTeacherId());
//                startActivity(intent);
//            }
//        });
//    }
//
//    @Override
//    public CoursesPresenter createPresenter() {
//        return new CoursesPresenter();
//    }
//
//    @Override
//    public void loadData() {
//        adapter.setEmptyView(loadingView);
//        Map params = new HashMap();
//        mPresenter.getCoursesListData(
//                page, PublicResources.PageSize, CoursesContract.CoursesType.Ordinary,params,null);
//    }
//
//    private void initView() {
//        refreshView = view.findViewById(R.id.refreshView);
//        refreshView.setPullRefreshEnable(true);
//        refreshView.setPullLoadEnable(false);
//        recyclerView = view.findViewById(R.id.recyclerView);
//        initEmptyView(recyclerView);
//        linearLayoutManager = new LinearLayoutManager(getActivity());
//        linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
//        recyclerView.setLayoutManager(linearLayoutManager);
//        adapter = new CourseTypeAdapter(R.layout.main_task_curriculum_adapter_item);
//        recyclerView.setAdapter(adapter);
//    }
//
//    @Override
//    public void setCoursestList(boolean isSuccess, int page, CoursesContract.CoursesType type, List<CoursesBean> data, String stDescribe) {
//        if(isSuccess&&data!=null){
//            if(page==1) {
//                if(data.size()==0){
//                    adapter.setEmptyView(noDataView);
//                }else {
//                    dataList = data;
//                    adapter.setNewData(dataList);
//                    adapter.notifyDataSetChanged();
//                    refreshView.stopRefresh();
//                    //显示数据大于20条才允许上拉加载更多
//                    if(dataList.size()>PublicResources.PageSize){
//                        refreshView.setPullLoadEnable(true);
//                    }
//                }
//            }else {
//                adapter.addData(data);
//                refreshView.stopLoadMore();
//            }
//        }else {
//            //如果是加载新数据时失败了 则page-1
//            if (page>1){
//                refreshView.stopLoadMore();
//                this.page--;
//            }else {
//                //还是还原为1防止出现负数
//                this.page = 1;
//                refreshView.stopRefresh();
//                adapter.setEmptyView(errorView);
//            }
//        }
//    }
//
//    @Override
//    public void setCoursesDetails(boolean isSuccess, CoursesBean data, String stDescribe) {
//
//    }
//
//    @Override
//    public void setCoursesTypeList(boolean isSuccess, List<CoursesTypeBean> data, String stDescribe) {
//
//    }
//
//    @Override
//    public void setCommentList(boolean isSuccess, int page, List<CommentBean> data, String stDescribe) {
//
//    }
//
//    @Override
//    public void actionComment(boolean isSuccess, String stDescribe) {
//
//    }
//
//}
